package com.imstlife.vending.listener;

import android.content.Context;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.widget.AdapterView;

import com.imstlife.vending.activity.DrinkInfoActivity;
import com.imstlife.vending.vo.DrinkInfo;

/**
 * Created by lihaifeng on 16/10/31.
 */
public class DrinkItemClickListener implements AdapterView.OnItemClickListener {


    private Context mContext;

    public DrinkItemClickListener(Context context) {
        this.mContext = context;
    }

    @Override
    public void onItemClick(AdapterView<?> adapterView, View view, int i, long l) {
        DrinkInfo drinkInfo = (DrinkInfo) adapterView.getItemAtPosition(i);
        if (drinkInfo.getCount() != 0 && drinkInfo.getPrice() != 0) {
            Intent intent = new Intent(mContext, DrinkInfoActivity.class);
            Bundle bundle = new Bundle();
            bundle.putSerializable("drinkinfo", drinkInfo);
            intent.putExtras(bundle);
            mContext.startActivity(intent);
        }
    }
}
